package com.sui.bigdata.rtcadmin.service.impl;

import com.sui.bigdata.rtcadmin.dto.KafkaTopicDto;
import com.sui.bigdata.rtcadmin.service.KafkaTopicService;
import com.sui.bigdata.rtcadmin.util.KafkaTopicUtil;
import org.springframework.stereotype.Service;

import java.util.List;


/**
 * @Author yanjiantong
 * @Date 2019/12/31 15:20
 * @Description
 * @email jiantong_yan@sui.com
 */
@Service
public class KafkaTopicServiceImpl implements KafkaTopicService {

    @Override
    public KafkaTopicDto queryAllTopic() {
        List<String> allTopicList = KafkaTopicUtil.queryAllTopic();
        String allTopic = String.join(",",  allTopicList.toArray(new String[allTopicList.size()]));
        return new KafkaTopicDto().setData(allTopic);
    }

    @Override
    public KafkaTopicDto queryByTopicName(String topicName) {
        String data = KafkaTopicUtil.consumerRecord(topicName);
        return new KafkaTopicDto().setData(data);
    }


}
